home *** CD-ROM | disk | FTP | other *** search
/ PC Answers 1995 May / PC Answers CD-ROM 7 (Future Publishing) (May 1995).iso / vbits / code / mee / vbdao / visdata / cpystru.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-10-06  |  5.5 KB  |  189 lines

  1. VERSION 2.00
  2. Begin Form fCpyStru 
  3.    BackColor       =   &H00C0C0C0&
  4.    BorderStyle     =   1  'Fixed Single
  5.    Caption         =   "Copy Table(s)"
  6.    ClientHeight    =   3300
  7.    ClientLeft      =   2730
  8.    ClientTop       =   2235
  9.    ClientWidth     =   6525
  10.    ControlBox      =   0   'False
  11.    Height          =   3705
  12.    Left            =   2670
  13.    LinkTopic       =   "Form1"
  14.    MaxButton       =   0   'False
  15.    MinButton       =   0   'False
  16.    ScaleHeight     =   3278.104
  17.    ScaleMode       =   0  'User
  18.    ScaleWidth      =   6554.436
  19.    Top             =   1890
  20.    Width           =   6645
  21.    Begin CheckBox cCopyData 
  22.       BackColor       =   &H00C0C0C0&
  23.       Caption         =   "Copy Data"
  24.       Height          =   255
  25.       Left            =   3675
  26.       TabIndex        =   9
  27.       Tag             =   "OLR"
  28.       Top             =   2310
  29.       Value           =   1  'Checked
  30.       Width           =   1623
  31.    End
  32.    Begin TextBox cDataBase 
  33.       BackColor       =   &H00FFFFFF&
  34.       Height          =   285
  35.       Left            =   3045
  36.       TabIndex        =   1
  37.       Tag             =   "OLS"
  38.       Top             =   420
  39.       Width           =   3375
  40.    End
  41.    Begin CommandButton CloseButton 
  42.       Cancel          =   -1  'True
  43.       Caption         =   "&Close"
  44.       Height          =   375
  45.       Left            =   4830
  46.       TabIndex        =   4
  47.       Top             =   2730
  48.       Width           =   1515
  49.    End
  50.    Begin CommandButton OkayButton 
  51.       Caption         =   "&OK"
  52.       Default         =   -1  'True
  53.       Height          =   375
  54.       Left            =   3045
  55.       TabIndex        =   3
  56.       Top             =   2730
  57.       Width           =   1485
  58.    End
  59.    Begin TextBox cConnect 
  60.       BackColor       =   &H00FFFFFF&
  61.       Height          =   540
  62.       Left            =   3045
  63.       MultiLine       =   -1  'True
  64.       TabIndex        =   0
  65.       Tag             =   "OLS"
  66.       Top             =   1155
  67.       Width           =   3375
  68.    End
  69.    Begin CheckBox cCopyIndexes 
  70.       BackColor       =   &H00C0C0C0&
  71.       Caption         =   "Copy Indexes"
  72.       Height          =   255
  73.       Left            =   3675
  74.       TabIndex        =   2
  75.       Tag             =   "OLR"
  76.       Top             =   1890
  77.       Value           =   1  'Checked
  78.       Width           =   1623
  79.    End
  80.    Begin ListBox cTableList 
  81.       BackColor       =   &H00FFFFFF&
  82.       Height          =   2760
  83.       Left            =   105
  84.       MultiSelect     =   2  'Extended
  85.       Sorted          =   -1  'True
  86.       TabIndex        =   5
  87.       Tag             =   "OLS"
  88.       Top             =   420
  89.       Width           =   2775
  90.    End
  91.    Begin Label ServerLabel 
  92.       BackColor       =   &H00C0C0C0&
  93.       Caption         =   "Target Connect String:"
  94.       Height          =   255
  95.       Left            =   3045
  96.       TabIndex        =   8
  97.       Top             =   840
  98.       Width           =   2115
  99.    End
  100.    Begin Label DataBaseLabel 
  101.       BackColor       =   &H00C0C0C0&
  102.       Caption         =   "Target Database:"
  103.       Height          =   225
  104.       Left            =   3045
  105.       TabIndex        =   7
  106.       Top             =   105
  107.       Width           =   1725
  108.    End
  109.    Begin Label TableListLabel 
  110.       BackColor       =   &H00C0C0C0&
  111.       Caption         =   "Tables:"
  112.       Height          =   225
  113.       Index           =   0
  114.       Left            =   105
  115.       TabIndex        =   6
  116.       Top             =   105
  117.       Width           =   2295
  118.    End
  119. Option Explicit
  120. Sub CloseButton_Click ()
  121.   RefreshTables fTables.cTableList, True  'just in case some were added
  122.   Unload Me
  123. End Sub
  124. Sub Form_Load ()
  125.   Dim i As Integer
  126.   RefreshTables cTableList, False
  127.   cDatabase = gstDBName
  128.   cConnect = gCurrentDB.Connect
  129.   Left = (Screen.Width - Width) / 2
  130.   Top = (Screen.Height - Height) / 2
  131. End Sub
  132. Sub Form_Paint ()
  133.   Outlines Me
  134. End Sub
  135. Sub OkayButton_Click ()
  136.   Dim i As Integer
  137.   Dim diff_db As Integer
  138.   Dim to_nm As String
  139.   Dim to_db As Database
  140.   Dim Connect As String
  141.   On Error GoTo OkayErr
  142.   MsgBar "Copying Table(s)", True
  143.   SetHourglass Me
  144.   If Len(cDatabase) = 0 Or cDatabase = gstDBName Then
  145.     Set to_db = gCurrentDB
  146.     diff_db = False
  147.   Else
  148.     Set to_db = OpenDatabase(cDatabase, False, False, cConnect & ";LoginTimeout=" & glLoginTimeout)
  149.     to_db.QueryTimeout = glQueryTimeout
  150.     diff_db = True
  151.   End If
  152.   For i = 0 To cTableList.ListCount - 1
  153.     If cTableList.Selected(i) Then
  154.       If diff_db = False Then
  155.         to_nm = InputBox("Enter New Table Name:")
  156.         If Len(to_nm) = 0 Then GoTo skipit
  157.       Else
  158.         to_nm = (cTableList.List(i))
  159.       End If
  160.     Else
  161.       GoTo skipit
  162.     End If
  163.     SetHourglass Me
  164.     If CopyStruct(gCurrentDB, to_db, (cTableList.List(i)), to_nm, (cCopyIndexes)) = True Then
  165.       If cCopyData = 1 Then
  166.         If CopyData(gCurrentDB, to_db, (cTableList.List(i)), to_nm) = False Then
  167.           Beep
  168.           MsgBox "Copy of Data To " & (cTableList.List(i)) & " was UnSuccessful!"
  169.         End If
  170.       End If
  171.       ResetMouse Me
  172.       MsgBox "Copy of " & (cTableList.List(i)) & " Structure was Successful!"
  173.       cTableList.Selected(i) = False
  174.     Else
  175.       ResetMouse Me
  176.       Beep
  177.       MsgBox "Copy of " & (cTableList.List(i)) & " UnSuccessful!"
  178.     End If
  179. skipit:
  180.   Next
  181.   GoTo OkayEnd
  182. OkayErr:
  183.   ShowError
  184.   Resume OkayEnd
  185. OkayEnd:
  186.   On Error Resume Next
  187.   MsgBar NULL_STR, False
  188. End Sub
  189.